import requests

s = requests.session()
print("登陆之前：", s.cookies)
# 学之思登录接口
url = "http://127.0.0.1:8000/api/user/login"
cs = {"userName": "admin", "password": "123456", "remember": False}
r = s.post(url, json=cs)
print(r.json())
assert r.json()['message'] == '成功'
assert r.json()['code'] == 1

url = "http://127.0.0.1:8000/api/admin/question/edit"
cs = {"id": 2, "questionType": 1, "subjectId": 2, "title": "一，计算100*2+4的结果，在下列选项中选择出唯一正确的选项。", "gradeLevel": 1,
      "items": [{"prefix":"A","content":"100"},{"prefix":"B","content":"204"},{"prefix":"C","content":"300"},{"prefix":"D","content":"400"}], "analyze": "100*2+4,应该先计算乘法，再计算加法，结果为204。", "correctArray":None,
          "correct": "B", "score": 10, "difficult": 4, "itemOrder": None}
cs2 = {"id": 5, "questionType": 2, "subjectId": 8, "title": "请在以下选项中选择出属于社会主义核心价值观的选项。", "gradeLevel": 2,
      "items": [{"prefix":"A","content":"富强","score":None,"itemUuid":None},{"prefix":"B","content":"民主","score":None,"itemUuid":None},{"prefix":"C","content":"坚韧","score":None,"itemUuid":None},{"prefix":"D","content":"帅气","score":None,"itemUuid":None}],
       "analyze": "社会主义核心价值观基本内容包括:富强、民主、文明、和谐、自由、平等、公正、法治、爱国、敬业、诚信、友善", "correctArray": ["A","B"],
          "correct":"A,B", "score": 7, "difficult": 3, "itemOrder": None}
cs3 = {"id": 7, "questionType": 4, "subjectId": 8, "title": "如何取代习近平，成为下一任国家主席：<span class=\"gapfilling-span aea89fcc-ce6a-4410-8444-426a87c4e359\">1</span>，并且保证连任<span class=\"gapfilling-span dc8bfafa-1606-4b5c-98fd-149ce60ce140\">2</span>", "gradeLevel": 2,
      "items": [{"id":None,"itemUuid":"aea89fcc-ce6a-4410-8444-426a87c4e359","prefix":"1","content":"刺杀他就行","score":60},{"id":None,"itemUuid":"dc8bfafa-1606-4b5c-98fd-149ce60ce140","prefix":"2","content":"修改宪法，只要活着就能连任","score":40}],
       "analyze": "自己悟吧","correct":"", "score": 100, "difficult": 5, "itemOrder": None}
r = s.post(url, json=cs3)
print("登陆之后：", s.cookies)
print(r.text)
assert r.json()['message'] == '成功'
assert r.json()['code'] == 1
